package com.project.dao;

import java.io.Serializable;
import java.util.List;

/**
 * Generic DAO Interface: Define generic method to process data from database.
 * 
 * @author travisl@synnex.com
 * 
 * @param <E>
 *            Entity
 * @param <P>
 *            Primary Key
 */
public interface GenericDAO<E extends Serializable, P extends Serializable> {
	/**
	 * generic method to save the entity instance to database.
	 * 
	 * @param entity
	 * @return primary key of entity
	 */
	public P save(E entity);

	/**
	 * generic method to save or update the entity instance to database.
	 * 
	 * @param entity
	 */
	public void saveOrUpdate(E entity);

	/**
	 * generic method to update the entity instance to database.
	 * 
	 * @param entity
	 */
	public void update(E entity);

	/**
	 * generic method to delete data by entity.
	 * 
	 * @param entity
	 */
	public void delete(E entity);

	/**
	 * generic method to get a entity by id from database.
	 * 
	 * @param id
	 * @return entity
	 */
	public E get(P id);

	/**
	 * generic method to get a all entity list from database.
	 * 
	 * @return entity list
	 */
	public List<E> listAll();

}
